package cn.dy.controller;

import cn.dy.pojo.Account;
import cn.dy.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/param")
public class ParamController {

    @RequestMapping("/testparam")
    public String testparam(String username,String pwd){
        System.out.println("testparam注解测试");
        System.out.println("用户名"+username+pwd);
        return "success";
    }

    @RequestMapping(value = "/saveAccount")
    public String saveAccount(Account account){
        System.out.println("saveAccount执行");
        System.out.println(account);
        return "success";
    }

    @RequestMapping(value = "/saveUser",method = RequestMethod.POST)
    public String saveUser(User user){
        System.out.println(user);
        return "success";
    }

    @RequestMapping("testServlet")
    public String testServlet(HttpServletRequest request, HttpServletResponse response){
        System.out.println(request);
        System.out.println(response);
        HttpSession session = request.getSession();
        System.out.println(session);
        ServletContext servletContext = session.getServletContext();
        System.out.println(servletContext);
        return "success";
    }

}
